define(function (require, exports, module) {

	var util = require('util');
	require('bootstrap-validator');

	exports.run = function () {

		var ajaxForm = $('form');

		//表单验证
		ajaxForm.bootstrapValidator({
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			fields : {
				title : {
					validators : {
						notEmpty : {
							message : '请填写分类名称'
						}
					}
				},
				name : {
					validators : {
						notEmpty : {
							message : '请填写分类编码'
						},
						regexp : {
							regexp : /^[a-z_]{1,20}$/,
							message : '分类编码必须为1-20位小写字母或下划线'
						}
					}
				}
			}
		}).on('success.form.bv', function (e) {
			util.ajaxModalSubmit(ajaxForm);
		});
	};

});